import sys
import os
# 获取 user 目录的绝对路径
user_dir = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'customize')
# 将 user 目录添加到 sys.path 中
sys.path.append(user_dir)
from customize.bocha_web_search import get_bocha_tool
from customize.get_ollama import GetOllama
r1 = GetOllama(model_type=1, model_name="qwen2.5:14b")()
search_tool = get_bocha_tool()

from langgraph.prebuilt import create_react_agent
agent = create_react_agent(r1, tools=[search_tool])
def print_stream(stream):
    for s in stream:
        message = s["messages"][-1]
        if isinstance(message, tuple):
            print(message)
        else:
            message.pretty_print()

inputs = {"messages": [("user", "3+5*4=?")]}
print_stream(agent.stream(inputs, stream_mode="values"))
